﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="CustomerContactSystem.WebForms.Customers.Search" %>
<%@ Import Namespace="CustomerContactSystem.Core.Infrastructure.Utility" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>Customers</h1>
<asp:HyperLink ID="CreateNewLink" runat="server" Text="Create New Customer" NavigateUrl="~/Customers/Create.aspx" CssClass="button"></asp:HyperLink>
<fieldset id="SearchForm" runat="server" class="search-form">
    <legend>Search</legend>

    <asp:Label ID="FirstNameCaption" runat="server" Text="First Name:" AssociatedControlID="FirstName"></asp:Label>
    <asp:TextBox ID="FirstName" runat="server"></asp:TextBox>

    <asp:Label ID="SecondNameCaption" runat="server" Text="Second Name:" AssociatedControlID="SecondName"></asp:Label>
    <asp:TextBox ID="SecondName" runat="server"></asp:TextBox>

    <asp:Label ID="AddressCaption" runat="server" Text="Address:" AssociatedControlID="Address"></asp:Label>
    <asp:TextBox ID="Address" runat="server"></asp:TextBox>
    
    <asp:label ID="ContactableOnlyCaption" runat="server" Text="Contactable Only?:" AssociatedControlID="ContactableOnly"></asp:label>
    <asp:checkbox ID="ContactableOnly" runat="server"></asp:checkbox>

    <asp:Button ID="SearchCustomers" runat="server" Text="Search" CssClass="submit" OnClick="SearchCustomersClick" />
    <asp:Label ID="SearchResultMessage" runat="server" CssClass="error"></asp:Label>
</fieldset>

<ul id="PagingList" runat="server" class="paging">
    <li><asp:HyperLink ID="FirstLink" runat="server" Text="First" NavigateUrl="~/Customers/Search.aspx" CssClass="button"></asp:HyperLink></li>
    <li><asp:HyperLink ID="PreviousLink" runat="server" Text="Previous" NavigateUrl="~/Customers/Search.aspx" CssClass="button"></asp:HyperLink></li>
    <li class="info"><asp:Literal ID="PagingInfo" runat="server">Page 1 of 20</asp:Literal></li>
    <li><asp:HyperLink ID="NextLink" runat="server" Text="Next" NavigateUrl="~/Customers/Search.aspx" CssClass="button"></asp:HyperLink></li>
    <li><asp:HyperLink ID="LastLink" runat="server" Text="Last" NavigateUrl="~/Customers/Search.aspx" CssClass="button"></asp:HyperLink></li>
</ul>
<asp:HyperLink ID="ExcelLink" runat="server" Target="_blank" CssClass="excel">
    <asp:Image ID="ExcelImage" runat="server" ImageUrl="~/Content/Images/excel.gif" AlternateText="View in Excel" />View in Excel
</asp:HyperLink>
<asp:Repeater ID="CustomerList" runat="server" OnItemDataBound="CustomerListItemDataBound">
<HeaderTemplate>
<table>
    <thead>
        <tr>
            <th id="Name">Name</th>
            <th id="Address">Address</th>
            <th id="Contactable">Contactable?</th>
            <th id="OptionsHeader" runat="server">Options</th>
        </tr>
    </thead>
    <tbody>
</HeaderTemplate>    
<ItemTemplate>
        <tr>
            <td id="NameCell" runat="server" headers="Name"><a id='<%#Eval("Id")%>'></a><%#Eval("FullName")%></td>
            <td id="AddressCell" runat="server" headers="Address"><%#Eval("AddressLine")%></td>
            <td id="ContactableCell" runat="server" headers="Contactable"><%#Eval("CanBeContactedForFeedback").ToString().ToYesNo()%></td>
            <td id="OptionsCell" runat="server">
                <asp:HyperLink ID="UseInNewEnquiryLink" runat="server" Text="Use in New Enquiry"></asp:HyperLink>
                <asp:HyperLink ID="ViewEnquiriesLink" runat="server" Text="View Enquiries"></asp:HyperLink>
                <asp:HyperLink ID="EditCustomerLink" runat="server" Text="Edit"></asp:HyperLink>
            </td>
        </tr>
</ItemTemplate>
<FooterTemplate>
    </tbody>
</table>
</FooterTemplate>
</asp:Repeater>    
</asp:Content>
